package seqAlignment;

import java.io.File;

import seqAlignment.utils.SubstitutionMatrix;

public class SequenceAlignmentor {
	
	SequenceAligner globalAligner;
	SequenceAligner localAligner;
	AffineGPLocalAligner agpLocalAligner;
	
	
	public SequenceAlignmentor(String str1, String str2) {
		globalAligner = new GlobalAligner();
		globalAligner.setSequences(str1, str2);
		globalAligner.init();
		localAligner = new LocalAligner();
		localAligner.setSequences(str1, str2);
		SubstitutionMatrix subMatrix = new SubstitutionMatrix();
		try {
			subMatrix.setFile(new File("/home/al/workspace/cs576_practice0/blosum-62.txt"));			
			//subMatrix.setFile(new File("D:\\java\\workspace\\cs576_practice0\\blosum-62.txt"));			
			//subMatrix.setFile(new File("C:\\java\\workspace\\cs576_practice0\\blosum-62.txt"));			
		} catch (Exception e) {
			e.printStackTrace();
		}
		SubMatrixAlignScore subMatrixAlgnScore = new SubMatrixAlignScore();
		subMatrixAlgnScore.setStr1(str1);
		subMatrixAlgnScore.setStr2(str2);
		subMatrixAlgnScore.setSubMatrix(subMatrix);
//		localAligner.setAlignmentScoreFunction(subMatrixAlgnScore);
//		localAligner.setGapPenaltyFunction(new LocalLinearGP(-1));
//		localAligner.init();
		
//	agpLocalAligner = new AffineGPLAlingerAllPaths();
		agpLocalAligner = new AffineGPLocalAligner();
		agpLocalAligner.setSequences(str1, str2);
		GapPenalty lnrGP=new AffineGapPenalty(-10,-1);
		agpLocalAligner.setAlignmentScoreFunction(subMatrixAlgnScore);
		agpLocalAligner.setGapPenaltyFunction(lnrGP);
		agpLocalAligner.init();
	}
	

	public void align() {
//		globalAligner.align();
//		localAligner.align();
		agpLocalAligner.align();
	}

	public void output() {
//		globalAligner.traceBack();
		//globalAligner.output();
//		localAligner.traceBack();
		//localAligner.output();
		agpLocalAligner.traceBack();
		agpLocalAligner.output();
	}

}
